package collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

public class CollectionTest2 {
	public static void main(String[] args) {
		test1();
	}

	/**
	 * collection collection list 方法的重载是在编译器就确定的,所以调用哪个重载方法看引用的类型就知道了,与运行期无关
	 * 
	 * @param c
	 */
	private static void test1(Collection<?> c) {
		System.out.println("collection");
	}

	private static void test1(List<?> c) {
		System.out.println("list");
	}

	public static void test1() {
		Collection<?> c1 = new HashSet<Object>();
		Collection<?> c2 = new ArrayList<Object>();
		List<?> c3 = new ArrayList<Object>();
		test1(c1);
		test1(c2);
		test1(c3);
	}
}
